package com.jushu.storbox.entities;

import android.content.ContentValues;
import android.database.Cursor;

import com.jushu.storbox.database.IObjectConvert;
import com.jushu.storbox.database.IUserDao;

public class User implements IObjectConvert {

	//basic infomation
	private String longName;
	private String encryPassword;
	private String userId;
	
	//extends infomation
	private String storePath;
	private String albumFolderId;
	private int AlbumEnabled = IUserDao.ALBUM_ENABLED_FALSE;;
	private int albumAutoBackup = IUserDao.ALBUM_AUTO_BACKUP_FALSE;
	private int backupAlbumOnlyWifi = IUserDao.ALBUM_BACKUP_ONLYWIFI_TRUE;;
	private int backupStoped = IUserDao.ALBUM_BACKUP_STOPED_FALSE;;
	
	public String getLongName() {
		return longName;
	}
	public void setLongName(String longName) {
		this.longName = longName;
	}
	public String getEncryPassword() {
		return encryPassword;
	}
	public void setEncryPassword(String encryPassword) {
		this.encryPassword = encryPassword;
	}
	public String getUserId() {
		return userId;
	}
	public void setUserId(String userId) {
		this.userId = userId;
	}
	public String getStorePath() {
		return storePath;
	}
	public void setStorePath(String storePath) {
		this.storePath = storePath;
	}
	public String getAlbumFolderId() {
		return albumFolderId;
	}
	public void setAlbumFolderId(String albumFolderId) {
		this.albumFolderId = albumFolderId;
	}
	public int getAlbumAutoBackup() {
		return albumAutoBackup;
	}
	public void setAlbumAutoBackup(int albumAutoBackup) {
		this.albumAutoBackup = albumAutoBackup;
	}
	public int getBackupAlbumOnlyWifi() {
		return backupAlbumOnlyWifi;
	}
	public void setBackupAlbumOnlyWifi(int backupAlbumOnlyWifi) {
		this.backupAlbumOnlyWifi = backupAlbumOnlyWifi;
	}
	public int getAlbumEnabled() {
		return AlbumEnabled;
	}
	public void setAlbumEnabled(int albumEnabled) {
		AlbumEnabled = albumEnabled;
	}
	public int getBackupStoped() {
		return backupStoped;
	}
	public void setBackupStoped(int backupStoped) {
		this.backupStoped = backupStoped;
	}
	
	@Override
	public void fromCursor(Cursor cursor) {
		setLongName(cursor.getString(cursor.getColumnIndex(IUserDao.LOGIN_NAME)));
		setEncryPassword(cursor.getString(cursor.getColumnIndex(IUserDao.ENCRY_PASSWORD)));
		setUserId(cursor.getString(cursor.getColumnIndex(IUserDao.USER_ID)));
		setStorePath(cursor.getString(cursor.getColumnIndex(IUserDao.STORE_PATH)));
		setAlbumFolderId(cursor.getString(cursor.getColumnIndex(IUserDao.ALBUM_FOLDER_ID)));
		setAlbumAutoBackup(cursor.getInt(cursor.getColumnIndex(IUserDao.ALBUM_AUTO_BACKUP)));
		setBackupAlbumOnlyWifi(cursor.getInt(cursor.getColumnIndex(IUserDao.ALBUM_BACKUP_ONLYWIFI)));
		setAlbumEnabled(cursor.getInt(cursor.getColumnIndex(IUserDao.ALBUM_ENABLED_FLAG)));
		setBackupStoped(cursor.getInt(cursor.getColumnIndex(IUserDao.ALBUM_BACK_STOP_FLAG)));
	}
	@Override
	public ContentValues toContentValues() {
		ContentValues cv = new ContentValues();
		cv.put(IUserDao.LOGIN_NAME, getLongName());
		cv.put(IUserDao.ENCRY_PASSWORD, getEncryPassword());
		cv.put(IUserDao.USER_ID, getUserId());
		cv.put(IUserDao.STORE_PATH, getStorePath());
		cv.put(IUserDao.ALBUM_FOLDER_ID, getAlbumFolderId());
		cv.put(IUserDao.ALBUM_AUTO_BACKUP, getAlbumAutoBackup());
		cv.put(IUserDao.ALBUM_BACKUP_ONLYWIFI, getBackupAlbumOnlyWifi());
		cv.put(IUserDao.ALBUM_ENABLED_FLAG, getAlbumEnabled());
		cv.put(IUserDao.ALBUM_BACK_STOP_FLAG, getBackupStoped());
		return cv;
	}
	
	public ContentValues getUpdateContentValues() {
		ContentValues cv = new ContentValues();
		cv.put(IUserDao.ENCRY_PASSWORD, getEncryPassword());
		cv.put(IUserDao.STORE_PATH, getStorePath());
		cv.put(IUserDao.ALBUM_FOLDER_ID, getAlbumFolderId());
		cv.put(IUserDao.ALBUM_BACKUP_ONLYWIFI, getBackupAlbumOnlyWifi());
		cv.put(IUserDao.ALBUM_ENABLED_FLAG, getAlbumEnabled());
		cv.put(IUserDao.ALBUM_BACK_STOP_FLAG, getBackupStoped());
		return cv;
	}
	
	public ContentValues getEncryPassContentValues() {
		ContentValues cv = new ContentValues();
		cv.put(IUserDao.ENCRY_PASSWORD, getEncryPassword());
		return cv;
	}
	
	public ContentValues getFolderIdContentValues() {
		ContentValues cv = new ContentValues();
		cv.put(IUserDao.ALBUM_FOLDER_ID, getAlbumFolderId());
		return cv;
	}
	
	public ContentValues getBackupFlagContentValues() {
		ContentValues cv = new ContentValues();
		cv.put(IUserDao.ALBUM_AUTO_BACKUP, getAlbumAutoBackup());
		return cv;
	}
	
	
	public ContentValues getWifiConfigCV() {
		ContentValues cv = new ContentValues();
		cv.put(IUserDao.ALBUM_FOLDER_ID, getAlbumFolderId());
		return cv;
	}
	
	public ContentValues getAlbumEnableCV() {
		ContentValues cv = new ContentValues();
		cv.put(IUserDao.ALBUM_ENABLED_FLAG, getAlbumEnabled());
		return cv;
	}
	
	public ContentValues getAlbumBackStopCV() {
		ContentValues cv = new ContentValues();
		cv.put(IUserDao.ALBUM_BACK_STOP_FLAG, getBackupStoped());
		return cv;
	}
}
